<!-- 一定要加上这一句，否则可能引入的时候导致乱码 -->
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<style>
.main {
  padding-right: 15%!important ;
  padding-left: 15%!important ;
}
</style>
    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container-fluid">
        <div class="navbar-header">
          <font size="4" class="navbar-brand" style="color: rgba(245, 245, 245, 0.82);">Wi-Fi数据分析系统</font>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
            <%--  
            <li <% if(request.getServletPath().indexOf("/main.jsp") != -1) { %> class="active" <% } %> ><a href="${path }/">首页 <span class="sr-only">(current)</span></a></li>
             --%>
			<li class='${param.active=="1"?"active":"" }' ><a href="${path }/data/account">数据分析</a></li>
			<li class='${param.active=="2"?"active":"" }' ><a href="${path }/dev/list">设备管理</a></li>
			<li class='${param.active=="3"?"active":"" }' ><a href="${path }/user/list">用户管理</a></li>
            <li class='${param.active=="4"?"active":"" }' ><a href="${path }/help">帮助</a></li>
          </ul>
          <ul class="nav navbar-nav navbar-right">
          	 
          	<li>
          		<a href="${path }/alarm/list"><span class="glyphicon glyphicon-bell" title="报警信息" style="font-size: 16px;color: #f5f5f5;"><span class="badge" style="margin-top: -25px;color: red;margin-left: -5px; display:none;" id="alarmNo">3</span></span>
          		</a>
          	</li>
          	 
            <% if(request.getAttribute("username") == null){ %>
            <li><a href="${path }/user/login">登录</a></li>
            <% } else { %>
            <li><a href="${path }/user/userinfo"> ${username }</a></li>
            <li><a href="${path }/user/logout">退出</a></li>
            <% } %>
          </ul>
          <!-- <form class="navbar-form navbar-right">
            <input type="text" class="form-control" placeholder="Search..." style="width: 140px;">
          </form> -->
        </div>
      </div>
    </nav>
    
    <script type="text/javascript">
    	getAlarmNoInfo();
    	function getAlarmNoInfo(){
				
	    	var defaultDate = Date.parse(new Date()) / 1000;
			var endTime = defaultDate;
			var startTime = defaultDate - 15*60;
			//console.log(endTime);
		    $.ajax({
		        type: "post",
		        url: "${path }/alarm/alarmList",
		        data: {
		        	"deviceNo" : '',
		        	"startTime" : startTime,
		        	"endTime" : endTime,
					"keywords" : ''
		        },
		        success: function(data) {
					if (data.totalCount > 0) {
						$("#alarmNo").show();
						$("#alarmNo").html(data.totalCount);
					} else {
						$("#alarmNo").hide();
						$("#alarmNo").html("");
					}
				},
				error : function(error) {
					console.log("getAlarmNoInfo() 错误代码：" + error.status + "。" + "错误内容:"+ error.statusText + "。");
				}
			});
		}
    	
    	//循环执行，每隔15秒钟执行一次 
    	window.setInterval(function(){ 
    		getAlarmNoInfo(); 
    	}, 5000); 
	</script>